package com.example.cloudalibabaconsumernacosorder83.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author chensixiang chensixiang1234@gmail.com
 */
@RestController
@Slf4j
public class OrderNacosController {

    @Resource
    private RestTemplate restTemplate;

    private static final String url = "http://nacos-payment-provider";

    @GetMapping("/consumer/nacos/{id}")
    public String payment(@PathVariable Integer id) {
        return restTemplate.getForObject(url + "/payment/nacos/" + id, String.class);
    }

}
